import { Method } from '@/common/enum/request-methods'

type IAPI = Record<string, [Method, string]>

/**
 * 项目路径 api
 * @author lian
 */
export const ProjectAPI: IAPI = {
  /** 随机获取一个项目 */
  getRandomProject: [Method.GET, '/projects/random'],
  /** 创建捐赠 */
  createProjectDonation: [Method.POST, '/projects/donations'],
  getProjectDetail: [Method.GET, '/projects/{id1}/detail'],
  getPagedProject: [Method.GET, '/projects'],
  // 创建项目
  createProject: [Method.POST, '/projects'],
}

/**
 * 活动路径 api
 * @author lian
 */
export const ActivityAPI: IAPI = {
  activity: [Method.GET, '/activities'],
  createActivity: [Method.POST, '/activities'],

  /** 随机获取项目 */
  getRandomActivity: [Method.GET, '/activities/random'],
  /** 报名与取消志愿者活动 */
  signupActivity: [Method.POST, '/activities/register'],
  cancelActivity: [Method.DELETE, '/activities/register'],
  /** 获取项目详情 */
  getActivityDetail: [Method.GET, '/activities/detail'],
}

/**
 * 动态路径 api
 * @author lian
 */
export const DynamicAPI: IAPI = {
  /** 分页获取动态 */
  dynamicBase: [Method.GET, '/dynamic'],
  // 创建动态
  createDynamic: [Method.POST, '/dynamic'],
  /** 获取动态详情 */
  getDynamicDetail: [Method.GET, '/dynamic/detail'],
  /** 获取动态的评论 */
  dynamicComment: [Method.GET, '/dynamic/comment'],
  // 创建动态评论
  createDynamicComment: [Method.POST, '/dynamic/comment'],
  /** 点赞 */
  dynamicLike: [Method.POST, '/dynamic/like'],
  /** 取消点赞 */
  dynamicUnlike: [Method.DELETE, '/dynamic/unlike'],
  /** 查询是否点赞 */
  dynamicCheckLike: [Method.GET, '/dynamic/check/like'],
}

/**
 * 用户路径 api
 * @author lian
 */
export const UsersAPI: IAPI = {
  /** 微信授权登录 */
  weChatLogin: [Method.POST, '/users/auth/wechat/login'],
  /** 自己参与的项目 */
  getMyProjects: [Method.GET, '/users/projects'],
  /** 自己发布的动态 */
  getMyDynamic: [Method.GET, '/users/dynamic'],
  /** 自己参与活动 */
  getMyActivity: [Method.GET, '/users/volunteer/activities'],
  /** 用户路径 */
  userBase: [Method.GET, '/users'],
  // 根据用户id更新用户信息
  updateUserInfo: [Method.PUT, '/users'],
  /** 管理员一键登录 */
  loginAdmin: [Method.POST, '/users/auth/admin/login'],
  /** 更新用户积分 */
  points: [Method.PUT, '/users/points'],
}

/**
 * 上传路径 api
 * @author lian
 */
export const UploadAPI: IAPI = {
  uploadAvatar: [Method.POST, '/upload'],
}

/**
 * 搜索路径 api
 * @author lian
 */
export const SearchAPI: IAPI = {
  search: [Method.GET, '/search'],
}

/**
 * 通知路径 api
 * @author lian
 */
export const NotificationAPI: IAPI = {
  notification: [Method.GET, '/notification'],
  // 创建通知
  createNotification: [Method.POST, '/notification'],
}

/**
 * 腾讯地图 api
 * @author lian
 */
export const TXMapAPI = {
  /** 地址转经纬度 */
  addressToCoder: 'https://apis.map.qq.com/ws/geocoder/v1',
}
